<template>
    <ui-main back>
        <div class="p20">
            <ui-title>我发布的彩金</ui-title>
            <router-link :to="{name:'彩金详情',query:{id:item.id}}" v-for="item in datalist" :key="item.id" class="flex col-center">
                <ui-img :url="item.company_ico || item.company_logo" size="50px" class="ui-circle bg-grey"></ui-img>
                <div class="flex-1 p15 ui-border-bottom">
                    <div class="clamp-1 f18 mb10">
                        <span class="f-color-blue">{{item.company_name}} </span>
                        <span>{{item.name}}</span>
                    </div>
                    <div class="f-color-grey">
                        <!-- 发布时间 -->
                        <span v-if="item.end_time && item.begin_time">{{item.begin_time}} 到 {{item.end_time}}</span>
                        <span v-else>{{item.create_time}}</span>

                        <!-- 1正常 2待审核 3新建 4审核驳回 -->
                        <el-tag v-if="item.status ==1" type="primary">正常</el-tag>
                        <el-tag v-if="item.status ==2" type="warning">待审核</el-tag>
                        <el-tag v-if="item.status ==3" type="success">新建</el-tag>
                        <el-tag v-if="item.status ==4" type="error">审核驳回</el-tag>
                    </div>
                </div>
            </router-link>

            <!-- 分页 -->
            <div class="text-center mt20">
                <el-pagination
                  @current-change="getDataList"
                  :current-page.sync="pageCurrent"
                  :page-size="pageSize"
                  layout="prev, pager, next, jumper"
                  :total="pageTotal">
                </el-pagination>
            </div>
        </div>
    </ui-main>
</template>
<script>
    export default {
        data(){
            return {
                datalist:[],
                pageCurrent:1,
                pageSize:9,
                pageTotal:0
            }
        },
        mounted(){
            this.getDataList()
        },
        methods:{
            getDataList(){
                this.$http.get('index.php?g=home&m=GameCoupon&a=user_coupon',{
                    params:{
                        page_size:this.pageSize,
                        page_no:this.pageCurrent,
                    }
                })
                .then(({data})=>{
                    console.log('已发布的彩金:',data)
                    if (data.code===1) {
                        this.datalist = data.data
                        this.pageTotal = parseInt(data.total)
                    }
                })
            }
        },
    }
</script>